#ifndef _HUFFTREE_H_
#define _HUFFTREE_H_

const unsigned char bl_count[] = {	// bit lengths count (there are only 7-9b codes)
0, 0, 0, 0, 0, 0, 0, 24, 144+8, 112, 0, 0, 0, 0, 0, 0, 0
};

const unsigned char static_ltree_lengths[] = {  // lengths of codes for values 0-287
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8,8,8,8,8,8,8,8
};

const short static_ltree_encoder[] = { // 7-9b codes for values 0-287
 12,140, 76,204, 44,172,108,236, 28,156, 92,220, 60,188,124,252,  2,130, 66,194,
 34,162, 98,226, 18,146, 82,210, 50,178,114,242, 10,138, 74,202, 42,170,106,234,
 26,154, 90,218, 58,186,122,250,  6,134, 70,198, 38,166,102,230, 22,150, 86,214,
 54,182,118,246, 14,142, 78,206, 46,174,110,238, 30,158, 94,222, 62,190,126,254,
  1,129, 65,193, 33,161, 97,225, 17,145, 81,209, 49,177,113,241,  9,137, 73,201,
 41,169,105,233, 25,153, 89,217, 57,185,121,249,  5,133, 69,197, 37,165,101,229,
 21,149, 85,213, 53,181,117,245, 13,141, 77,205, 45,173,109,237, 29,157, 93,221,
 61,189,125,253, 19,275,147,403, 83,339,211,467, 51,307,179,435,115,371,243,499,
 11,267,139,395, 75,331,203,459, 43,299,171,427,107,363,235,491, 27,283,155,411,
 91,347,219,475, 59,315,187,443,123,379,251,507,  7,263,135,391, 71,327,199,455,
 39,295,167,423,103,359,231,487, 23,279,151,407, 87,343,215,471, 55,311,183,439,
119,375,247,503, 15,271,143,399, 79,335,207,463, 47,303,175,431,111,367,239,495,
 31,287,159,415, 95,351,223,479, 63,319,191,447,127,383,255,511,  0, 64, 32, 96,
 16, 80, 48,112,  8, 72, 40,104, 24, 88, 56,120,  4, 68, 36,100, 20, 84, 52,116,
  3,131, 67,195, 35,163, 99,227
};

const short static_ltree_decoder[] = {  // values 0-287
256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,
276,277,278,279,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,
116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,
136,137,138,139,140,141,142,143,280,281,282,283,284,285,286,287,144,145,146,147,
148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,
168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,
188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,
228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,
248,249,250,251,252,253,254,255
};

const unsigned char static_dtree_encoder[] = {  // all 5bit long codes for values 0-29
0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23
};

const unsigned char static_dtree_decoder[] = {  // -1 will never happen; values 0-29
0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,-1,1,17,9,25,5,21,13,29,3,19,11,27,7,23,15
};

const unsigned int base_dist[] = {  // distance base values
    0,     1,     2,     3,     4,     6,     8,    12,    16,    24,
   32,    48,    64,    96,   128,   192,   256,   384,   512,   768,
 1024,  1536,  2048,  3072,  4096,  6144,  8192, 12288, 16384, 24576
};

const unsigned short base_length[] = {  // length base values
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
64, 80, 96, 112, 128, 160, 192, 224, 255
};


#endif  // _HUFFTREE_H_